package echat.future.cn.echat.message.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import echat.future.cn.echat.R;
import echat.future.cn.echat.message.MessageApi;
import echat.future.cn.echat.message.adapter.MyCallAdapter;
import echat.future.cn.echat.message.bean.EbiBean;
import echat.future.cn.echat.message.bean.MyCallBean;
import echat.future.cn.echat.my.utils.HttpUtilsRequst;
import echat.future.cn.echat.my.utils.UserHelper;
import lumingweihua.future.cn.baselibgxh.base.BaseActivity;

/**
 * 我的通话
 * Created by JX on 2018/8/12.
 */

public class MyCallActivity extends BaseActivity {

    private RecyclerView rv;

    private MyCallAdapter mAdapter;
    private List<MyCallBean> mData;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_mycall);

        findViewById(R.id.iv_back).setOnClickListener(this);

        mData = new ArrayList<>();

        rv = findViewById(R.id.mycall_rv);
        mAdapter = new MyCallAdapter(R.layout.message_mycall_rv_item, mData);
        mAdapter.bindToRecyclerView(rv);
        rv.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    protected void initData() {
        new HttpUtilsRequst<List<MyCallBean>>(this, HttpUtilsRequst.retrofitClient.create(MessageApi.class)
                .mycall_get(UserHelper.getToken(),1))
                .setmOnRequstSuccessListener(new HttpUtilsRequst.OnRequstSuccessListener<List<MyCallBean>>() {
                    @Override
                    public void onSuccss(List<MyCallBean> MyCallBeans) {
                        mData.addAll(MyCallBeans);
                        mAdapter.notifyDataSetChanged();
                    }
                }).start();
    }

    @Override
    protected void processClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}